//数字转化为罗马数字

function toRoman(num){
	if(isNaN(num)) return num;
	
	var a=[["","I","II","III","IV","V","VI","VII","VIII","IX"],
                  ["","X","XX","XXX","XL","L","LX","LXX","LXXX","XCC"],
                  ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"]];
	var roman = "";
	var t=0;
	for(var m=0, i=1000; m<3; m++,i/=10){
     	t=Math.floor((num%i)/(i/10));
    	roman += a[2-m][t];
    }
	return roman;
}
	

//  应急响应
function eResponse(id){
	n2.ajax.get('http://'+n2.YingjiT,{eq_ID:id},'').then(function(res){
		var res = JSON.parse(res);
		
		
		
		//标题
		var title = res.name;
		
		var titleId = document.getElementById('titleId');
		titleId.innerHTML = title;
		
		//响应级别
		var level = res.emergencyResponseValue;
		var levelId = document.getElementById('levelId');
		levelId.innerHTML = toRoman(level);
		
		//响应内容
		var baseicInfo = res.basicInfo;
		var baseicInfoId = document.getElementById('baseicInfoId');
		baseicInfoId.innerHTML = baseicInfo;
		//工作组
		
		var reliefLinePoint = res.reliefLinePoint;

		var ulTable = document.querySelector('.mui-table-view');
		
		ulTable.innerHTML = '';
		
		var workLen = reliefLinePoint.length;

		
		for (var i=0;i<workLen;i++){
			var li = document.createElement('li');
			li.className = 'mui-table-view-cell';
			
			var span = document.createElement('span');
			span.className = 'mui-icon mui-icon-compose pull-right';
			span.style = 'margin-top: 20px; color: red;';
			span.title = id;
			li.appendChild(span)
			
			span.addEventListener('tap', function(event) {
				mui.openWindow({
					url: 'baogaorzhi.html',
					id: 'baogaorzhi',
					preload: true,
					show: {
						autoShow:true,//页面loaded事件发生后自动显示，默认为true
						aniShow: 'pop-in',
						duration:'100',
					},
					styles: {
						popGesture: 'close',
						hardwareAccelerated:true
					},
					waiting: {
						autoShow: true
					}
				});
			}, false);
			
			var h5 = document.createElement('h5');
			li.appendChild(h5);
			var a = document.createElement('a');
			a.innerHTML = reliefLinePoint[i].position;
			h5.appendChild(a);
			
			
			//时间  time
			var time = reliefLinePoint[i].time;
			var dt2 = new Date(time);
			var loTime = dt2.getFullYear()+'年'+(dt2.getMonth() + 1)+'月'+dt2.getDate()+'日';
			var h6 = document.createElement('h6');
			h6.innerHTML = '到达时间：'+loTime+'&nbsp;&nbsp;&nbsp;'+'工作天数：3天';
			li.appendChild(h6);
			
			ulTable.appendChild(li);			
		}
	})
}
